package com.yzzrjy.controller.mainservlet.register;

import com.yzzrjy.Service.UserService;
import com.yzzrjy.util.ResponseUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;


@WebServlet(name = "RegisterInfoServlet", value = "/registerInfo")
public class RegisterInfoServlet extends HttpServlet {
    private UserService userService = new UserService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid = request.getParameter("uid");
        String nickName = request.getParameter("nickname");
        String sex = request.getParameter("sex");
        if(uid == null || nickName == null || sex == null){
            ResponseUtils.parameterError(response);
            return;
        }

        try {
            userService.registerInfo(uid, nickName, sex);
            ResponseUtils.success(response, null);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
